<!-- 
 -->
<html>

<head>
    <title>Canvas tutorial</title>
    <script type="text/javascript">
        function draw() {
            var ctx = document.getElementById('canvas').getContext('2d');
            var img = new Image();
            img.onload = function () {
                for (var i = 0; i < 4; i++) {
                    for (var j = 0; j < 3; j++) {
                        ctx.drawImage(img, j * 50, i * 38, 50, 38);
                    }
                }
            };
            img.src = 'https://mdn.mozillademos.org/files/5397/rhino.jpg';
        }
    </script>
    <style type="text/css">
        canvas {
            border: 1px solid black;
        }
    </style>
</head>

<body onload="draw();">
    <canvas id="canvas" width="500" height="500"></canvas>
</body>

</html>